//package org.activoricordi.app.snippet
package edu.ucdavis.fiehnlab.alchemy.alchemyAdmin.snippet

/**
 * Created with IntelliJ IDEA.
 * User: naru
 * Date: 3/28/13
 * Time: 4:36 PM
 * To change this template use File | Settings | File Templates.
 */
import net.liftweb.common.{Box,Full,Empty,Failure,ParamFailure}
import net.liftweb._
import  edu.ucdavis.fiehnlab.alchemy.alchemyAdmin.model._
import util._
import Helpers._
import http._

import scala.xml._

class ListMethod {
  /**
   *
   * list all Method from Databases
   *
   */
  def list(html: NodeSeq) : NodeSeq = {
    toShow.flatMap(method =>
      bind("method", html,
        "name" -> method.name,
        "riWindow" -> method.riWindow,
        "massWindow" ->method.massWindow,
        "description" -> method.description,

        /**
         *  View Link for Method
         */
        FuncAttrBindParam("view_href", _ =>
          Text("view/"+ (method.primaryKeyField)),"href"),

        /**
         *  edit link for Method
         */
        FuncAttrBindParam("edit_href", _ =>
          Text("edit/"+ (method.primaryKeyField)),"href"),

        /**
         *  delete link for Method
         */
        FuncAttrBindParam("delete_href", _ =>
          Text("delete/"+ (method.primaryKeyField)),"href")
      )
    )
  }

  /**
   *
   * call the function with input  Compound object
   */
  private def toShow =
    Method.findAll()

}